

*** compute SW F stats for multiple endogenous variables 

***Inputs: 
* $Data/normscore_IV60_ability.dta

***Outputs: 
* $Results/ability_SWF.tex


	use $Data/normscore_IV60_ability.dta, clear

forval x = 1(1)5 {
	
	gen highpm_quintile`x' = highpm* (quinresid ==`x')
	
}




ivreghdfe highpm_quintile1 (highpm_quintile2 highpm_quintile3 highpm_quintile4 highpm_quintile5  = c.maxzipwind#i.quinresid ) weighted_wind_speed weighted_precipitation , absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

predict pmquintile1hat 

gen pmresid1 = highpm_quintile1 - pmquintile1hat 

reghdfe pmresid1 c.maxzipwind#i.quinresid weighted_wind_speed weighted_precipitation, absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

test 1.quinresid#c.maxzipwind 2.quinresid#c.maxzipwind 3.quinresid#c.maxzipwind 4.quinresid#c.maxzipwind 5.quinresid#c.maxzipwind
scalar FSW1 = r(F)*r(df)/(r(df)-1)
di FSW1





ivreghdfe highpm_quintile2 (highpm_quintile1 highpm_quintile3 highpm_quintile4 highpm_quintile5  = c.maxzipwind#i.quinresid ) weighted_wind_speed weighted_precipitation , absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

predict pmquintile2hat 

gen pmresid2 = highpm_quintile2 - pmquintile2hat 

reghdfe pmresid2 c.maxzipwind#i.quinresid weighted_wind_speed weighted_precipitation, absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

test 1.quinresid#c.maxzipwind 2.quinresid#c.maxzipwind 3.quinresid#c.maxzipwind 4.quinresid#c.maxzipwind 5.quinresid#c.maxzipwind
scalar FSW2 = r(F)*r(df)/(r(df)-1)
di FSW2








ivreghdfe highpm_quintile3 (highpm_quintile1 highpm_quintile2 highpm_quintile4 highpm_quintile5  = c.maxzipwind#i.quinresid ) weighted_wind_speed weighted_precipitation , absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

predict pmquintile3hat 

gen pmresid3 = highpm_quintile3 - pmquintile3hat 

reghdfe pmresid3 c.maxzipwind#i.quinresid weighted_wind_speed weighted_precipitation, absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

test 1.quinresid#c.maxzipwind 2.quinresid#c.maxzipwind 3.quinresid#c.maxzipwind 4.quinresid#c.maxzipwind 5.quinresid#c.maxzipwind
scalar FSW3 = r(F)*r(df)/(r(df)-1)
di FSW3










ivreghdfe highpm_quintile4 (highpm_quintile1 highpm_quintile2 highpm_quintile3 highpm_quintile5  = c.maxzipwind#i.quinresid ) weighted_wind_speed weighted_precipitation , absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

predict pmquintile4hat 

gen pmresid4 = highpm_quintile4 - pmquintile4hat 

reghdfe pmresid4 c.maxzipwind#i.quinresid weighted_wind_speed weighted_precipitation, absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

test 1.quinresid#c.maxzipwind 2.quinresid#c.maxzipwind 3.quinresid#c.maxzipwind 4.quinresid#c.maxzipwind 5.quinresid#c.maxzipwind
scalar FSW4 = r(F)*r(df)/(r(df)-1)
di FSW4








ivreghdfe highpm_quintile5 (highpm_quintile1 highpm_quintile2 highpm_quintile3 highpm_quintile4  = c.maxzipwind#i.quinresid ) weighted_wind_speed weighted_precipitation , absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

predict pmquintile5hat 

gen pmresid5 = highpm_quintile5 - pmquintile5hat 

reghdfe pmresid5 c.maxzipwind#i.quinresid weighted_wind_speed weighted_precipitation, absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

test 1.quinresid#c.maxzipwind 2.quinresid#c.maxzipwind 3.quinresid#c.maxzipwind 4.quinresid#c.maxzipwind 5.quinresid#c.maxzipwind
scalar FSW5 = r(F)*r(df)/(r(df)-1)
di FSW5


matrix Fstats = [FSW1 , FSW2, FSW3, FSW4, FSW5]'


estout matrix(Fstats) using $Results/ability_SWF.tex, replace





